package com.i8office.android.zhihuixinwu.module.model;

import com.cyan.tools.callback.RequestCallback;
import com.i8office.android.zhihuixinwu.app.App;
import com.i8office.android.zhihuixinwu.bean.Code;
import com.i8office.android.zhihuixinwu.bean.Result;
import com.i8office.android.zhihuixinwu.bean.WorkFlowUnRead;
import com.i8office.android.zhihuixinwu.module.contract.OfficeContract;
import com.i8office.android.zhihuixinwu.util.OfficeSubscriber;

import java.util.ArrayList;
import java.util.Map;

import bean.WorkFlow;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by pc on 2018/7/7.
 */

public class OfficeModel implements OfficeContract.Model {
    @Override
    public Disposable getDeals(RequestCallback<ArrayList<WorkFlow>> callback, Map<String, String> param) {
        return App.getComponent().getAPIService().getDeals(param).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new OfficeSubscriber<Result<ArrayList<WorkFlow>>>(callback));
    }

    @Override
    public Disposable getPending(RequestCallback<ArrayList<WorkFlow>> callback, Map<String, String> param) {
        return App.getComponent().getAPIService().getPending(param).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new OfficeSubscriber<Result<ArrayList<WorkFlow>>>(callback));
    }

    @Override
    public Disposable getPendingDep(RequestCallback<ArrayList<WorkFlow>> callback, Map<String, String> param) {
        return App.getComponent().getAPIService().getPendingDep(param).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new OfficeSubscriber<Result<ArrayList<WorkFlow>>>(callback));
    }
    @Override
    public Disposable getPendingDepDeal(RequestCallback<ArrayList<WorkFlow>> callback, Map<String, String> param) {
        return App.getComponent().getAPIService().getPendingDepDeal(param).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new OfficeSubscriber<Result<ArrayList<WorkFlow>>>(callback));
    }

    @Override
    public Disposable getFavoriteList(RequestCallback<ArrayList<WorkFlow>> callback, Map<String, String> param) {
        return App.getComponent().getAPIService().getFavoriteList(param).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new OfficeSubscriber<Result<ArrayList<WorkFlow>>>(callback));
    }

    @Override
    public Disposable getFavoriteDepList(RequestCallback<ArrayList<WorkFlow>> callback, Map<String, String> param) {
        return App.getComponent().getAPIService().getFavoriteDepList(param).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new OfficeSubscriber<Result<ArrayList<WorkFlow>>>(callback));
    }

    @Override
    public Disposable getNotify(RequestCallback<WorkFlowUnRead> callback, Map<String, String> param) {
        return App.getComponent().getAPIService().getNotify(param).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new OfficeSubscriber<WorkFlowUnRead>(callback));
    }

    @Override
    public Disposable read(RequestCallback<Code> callback, Map<String, String> params) {
        return App.getComponent().getAPIService().read(params).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeWith(new OfficeSubscriber<Code>(callback));

    }
}
